package com.bankscene.screenfit.vus;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ListAdapter;

import com.bankscene.screenfit.R;
import com.bankscene.screenfit.events.EventBusEvents;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;

/**
 * Created by jiiiiiin on 6/14/16.
 */
public class MenusGridViewVu extends BaseVu implements Vu {

    @BindView(R.id.gridview)
    GridView gridview;

    @Override
    public void init(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable EventBus bus) {
        this.bus = bus;
        rootView = inflater.inflate(R.layout.menusgridview_fragment, container, false);
        unbinder = ButterKnife.bind(this, rootView);
    }

    @OnItemClick(value = R.id.gridview)
    void OnItemClick(int position) {
        bus.post(new EventBusEvents.OnItemClickEvent(position));
    }

    public void setListAdapter(@NonNull ListAdapter adapter) {
        gridview.setAdapter(adapter);
    }

}
